import Vue from 'vue'
import Router from 'vue-router'

// 登录
import Login from '@/views/Login'

// 主界面
import Main from "@/views/Main"

// 首页
import Home from "@/views/Home"
// 菜单管理
import Menu from "@/views/menu/Menu"
// 分类管理
import Type from "@/views/type/Type"
// 商品管理
import Good from "@/views/good/Good"
// 用户管理
import User from "@/views/user/User"

Vue.use(Router)

const originalReplace = Router.prototype.replace;
Router.prototype.replace = function replace(location) {
	return originalReplace.call(this, location).catch(err => err);
};


export default new Router({
	mode: "history",
	routes: [
		{
			path: '/',
			name: 'login',
			component: Login,
		}, {
			path: "/main",
			name: "main",
			component: Main,
			redirect: "home",
			children: [{
				path: "/home",
				name: "home",
				component: Home,
				meta: {
					title: "首页",
					icon: "el-icon-s-home"
				}
			}, {
				path: "/menu",
				name: "menu",
				component: Menu,
				meta: {
					title: "菜单管理",
					icon: "el-icon-menu"
				}
			}, {
				path: "/type",
				name: "type",
				component: Type,
				meta: {
					title: "分类管理",
					icon: "el-icon-s-order"
				}
			}, {
				path: "/good",
				name: "good",
				component: Good,
				meta: {
					title: "商品管理",
					icon: "el-icon-s-order"
				}
			}, {
				path: "/user",
				name: "user",
				component: User,
				meta: {
					title: "用户管理",
					icon: "el-icon-user-solid"
				}
			}]
		}
	]
})
